import Vue from 'vue'
import { storage } from '@/utils/base.js'

Vue.directive('has', {
  inserted: function (el, binding, vnode) {
    if (!hasPermission(binding.value)) {
      el.parentNode.removeChild(el)
    }
  }
})

export function hasPermission(value) {
  let list = storage.get('buttonPermission')
  if (list) {
    for (const item of list) {
      if (item.name == value) {
        return true
      }
    }
  }
  return false
}
